package com.yj.spring.charpter02;

import com.yj.spring.common.BeanDefinition;

public class ClassPathXmlApplicationContext {

    BeanFactory beanFactory;


    public ClassPathXmlApplicationContext(String configLocation) {
        ClassPathXmlResource resource = new ClassPathXmlResource(configLocation);
        beanFactory = new SimpleBeanFactory();
        XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
        beanDefinitionReader.loadBeanDefinitions(resource);

    }

    public Object getBean(String beanName) {
        return beanFactory.getBean(beanName);
    }

    public void registerBeanDefinition(BeanDefinition beanDefinition) {
        beanFactory.registerBeanDefinition(beanDefinition);
    }

}
